package cn.le.poster.entity;


import cn.le.poster.PosterElement;
import cn.le.poster.element.Canvas;
import cn.le.poster.element.Graphical;
import cn.le.poster.element.Img;
import cn.le.poster.element.Text;
import cn.le.poster.enums.EnumShape;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

public class SamplePoster {

    /**
     * 画板
     */
    private Canvas canvas;

    List<PosterElement> posterElements = new ArrayList<PosterElement>();

    public static SamplePoster build(){
        return new SamplePoster();
    }

    /**
     * 画板
     * @param w
     * @param h
     * @param color
     */
    public SamplePoster canvas(int w, int h, Color color){
        canvas = new Canvas(w,h,color);
        return this;
    }

    /**
     * 设置图片
     * @param w
     * @param h
     * @param image
     */
    public SamplePoster img(int w, int h, BufferedImage image){
        img(w,h,0,0,image, EnumShape.None);
        return this;
    }

    /**
     * 图片
     * @param w
     * @param h
     * @param x
     * @param y
     * @param image
     * @param shape
     */
    public SamplePoster img(int w, int h, int x, int y, BufferedImage image, EnumShape shape){
        Img img = new Img(w,h,x,y,image,shape);
        posterElements.add(img);
        return this;
    }

    /**
     * 涂色
     * @param w
     * @param h
     * @param x
     * @param y
     * @return
     */
    public SamplePoster graphical(int w, int h, int x, int y, Color color){
        Graphical graphical = new Graphical(w,h,x,y,color);
        posterElements.add(graphical);
        return this;
    }

    public SamplePoster graphical(int w, int h, int x, int y, Color color, EnumShape shape, int arcW, int arcH){
        Graphical graphical = new Graphical(w,h,x,y,color,shape,arcW,arcH);
        posterElements.add(graphical);
        return this;
    }

    public SamplePoster text(String text, int x, int y, Font font, Color color){
        Text text1 = new Text(text,x,y,font,color);
        posterElements.add(text1);
        return this;
    }

    public Canvas getCanvas(){
        return canvas;
    }

    public List<PosterElement> getPosterElements() {
        return posterElements;
    }
}
